import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

export default new VueRouter({
     routes:[
         {
             path: '/',
             name: 'login',
             component: () => import('../components/Login')
         },
         {
             path:'/Index',
             name:'Index',
             component:()=>import('../components/Index'),
             children:[
                 {
                     path:'/Home',
                     name:'Home',
                     meta:{
                         title:'首页',
                     },
                     component:()=>import('../components/Home')
                 },
                 // {
                 //     path:'/Admin',
                 //     name:'Admin',
                 //     meta:{
                 //         title: '管理员管理'
                 //     },
                 //     component:()=>import('../components/admin/AdminManage')
                 // },
                 // {
                 //     path:'/User',
                 //     name:'User',
                 //     meta:{
                 //         title: '用户管理'
                 //     },
                 //     component:()=>import('../components/user/UserManage')
                 // },
             ]
         },
     ]
})


export function resetRouter() {
    VueRouter.matcher = new VueRouter({
        mode:'history',
        routes: []
    }).matcher
}

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}